"""链接到sql"""
import mysql.connector as mc

def py_db_insert():
    try:
        com = mc.connect(
            host = "127.0.0.1",
            port = "3306",
            user = "root",
            password = "05130422",
            database = "zuoye",
            charset = "utf8"
        )
    except mc.Error as e:
        print("连接失败！！")
    else:
        print("连接成功")








"""链接表格中的第一张表"""
import xlrd
import xlwt

def xl_Sele():
    wb=xlrd.open_workbook(r"D:\作业\需求\人员信息表.xls")
    sheet1 = wb.sheet_by_index(0)

    row = sheet1.col_values(4)
    print(row)

def xl_Insert():
    row = xl_Sele()
    # 创建文件  写在结束的位置
    wt = xlwt.Workbook()
    # 创建sheet页  add_sheet()
    sheet1 = wt.add_sheet(u"sheet1")
    sheet1.write(0, 0,row)

    wt.save(r"D:\作业\需求\只有人名表.xls")









# com.close()


if __name__ == '__main__':
    py_db_insert()
    xl_Sele()
    xl_Insert()

























































































